home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1996 #6
/
Amiga Plus CD - 1996 - No. 06.iso
/
pd
/
tools
/
pc-heiniv0.56
/
source
/
mainwindow.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-08-02
|
9KB
|
235 lines
/*
**
** mainwindow.h Release 1
**
** Mainwin Class
** derived from MUIC_Window
** controlls inputevents, opens menus
** and a Popgroup Object
** includes About- and AboutMUI-Requesters
**
** ©1996 Ctryxx/Trinomic (Stephan Quitzsch)
**
*/
#define Mainwin_Base 0x2 // first digit
#define MUIM_Mainwin_About 0x222
#define MUIM_Mainwin_Abmui 0x223
#define MUIM_Mainwin_Close 0x224
#define MUIM_Mainwin_Quit 0x225
#define MUIM_Mainwin_New 0x226
#define CNT_MAXWIN 10 // never > 0xFF !!!
/*============================================================================*/
struct MUI_CustomClass *CL_Mainwin;
/*============================================================================*/
struct MUIP_Mainwin_Test { ULONG MethodID; int count; };
static char wndcnt = 0; // counts open mainwindows
/*============================================================================*/
/*= Mainwin class =*/
/*============================================================================*/
struct Mainwin_Data
{
APTR mui_popgroup; // Objects
APTR mui_about;
APTR mui_muiab;
APTR mui_new;
APTR mui_open;
APTR mui_prt;
APTR mui_quit;
APTR mui_seek;
APTR mui_fwd;
APTR mui_bwd;
};
/*============================================================================*/
ULONG Mainwin_Close( struct IClass *cl, Object *obj, Msg msg ) // Close Window
{
set( obj, MUIA_Window_Open, FALSE );
wndcnt--;
if( wndcnt == 0 )
{
DoMethod( xget(obj, MUIA_ApplicationObject), MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
return (ULONG)obj;
}
DoMethod( xget(obj, MUIA_ApplicationObject), OM_REMMEMBER, obj );
MUI_DisposeObject( obj ); // kill Window Object
return 0l;
}
ULONG Mainwin_Quit( struct IClass *cl, Object *obj, Msg msg ) // Quit whole Application
{
DoMethod( xget(obj, MUIA_ApplicationObject), MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
return (ULONG)obj;
}
ULONG Mainwin_About( struct IClass *cl, Object *obj, Msg msg ) // About PC-Heini
{
MUI_RequestA( (APTR)xget(obj, MUIA_ApplicationObject), 0l, 0l, PCH_VERS, "Oki", "PC-Heini\nby Ctryxx/Trinomic 1995-96\nwir95ccv@manitu.rz.uni-leipzig.de", 0 );
return 0l;
}
ULONG Mainwin_Newwin( struct IClass *cl, Object *obj, Msg msg ) // New Window
{
APTR mui_nwin;
LONG app = xget( obj, MUIA_ApplicationObject );
if( wndcnt > CNT_MAXWIN )
{
MUI_RequestA( 0l, 0l, 0l, "PC-Heini message", "Grumpf!", "I think, it's enough, isn't it?", 0 );
return 0l;
}
mui_nwin = NewObject( CL_Mainwin->mcc_Class, NULL, TAG_DONE );
if( mui_nwin )
{
DoMethod( app, OM_ADDMEMBER, mui_nwin );
set( mui_nwin, MUIA_Window_Open, TRUE );
}
else MUI_RequestA( 0l, 0l, 0l, "An Error came up!", "Ok|Cancel", "Can't open window!", 0 );
return 0l;
}
ULONG Mainwin_Abmui( struct IClass *cl, Object *obj, Msg msg ) // About MUI
{
static APTR mui_awin = 0l;
if( !mui_awin )
{ mui_awin = AboutmuiObject, MUIA_Aboutmui_Application, xget( obj, MUIA_ApplicationObject ), End;
}
if( mui_awin ) set( mui_awin, MUIA_Window_Open, TRUE );
return 0l;
}
ULONG Mainwin_New( struct IClass *cl, Object *obj, Msg msg )
{
APTR mui_pgrp; // Objects
APTR mui_new;
APTR mui_open;
APTR mui_prt;
APTR mui_about;
APTR mui_muiab;
APTR mui_quit;
APTR mui_seek;
APTR mui_fwd;
APTR mui_bwd;
struct Mainwin_Data *data;
obj = (Object*) DoSuperNew( cl, obj,
MUIA_Window_ID, 0x50434800+wndcnt,
MUIA_Window_AppWindow, TRUE,
MUIA_Window_Title, "PC-Heini by Ctryxx",
MUIA_Window_Height, MUIV_Window_Height_Screen(100),
MUIA_Window_Width, MUIV_Window_Width_Screen(100),
MUIA_Window_Menustrip, MenustripObject,
MUIA_Family_Child, MenuObject,
MUIA_Menu_Title, "Project",
MUIA_Family_Child, mui_new = MenuitemObject, MUIA_Menuitem_Title, "New", MUIA_Menuitem_Shortcut, "N", End,
MUIA_Family_Child, mui_open = MenuitemObject, MUIA_Menuitem_Title, "Open", MUIA_Menuitem_Shortcut, "O", End,
MUIA_Family_Child, mui_prt = MenuitemObject, MUIA_Menuitem_Title, "Print", MUIA_Menuitem_Shortcut, "P", End,
MUIA_Family_Child, mui_about = MenuitemObject, MUIA_Menuitem_Title, "About PC-Heini", MUIA_Menuitem_Shortcut, "A", End,
MUIA_Family_Child, mui_muiab = MenuitemObject, MUIA_Menuitem_Title, "About MUI", MUIA_Menuitem_Shortcut, "M", End,
MUIA_Family_Child, mui_quit = MenuitemObject, MUIA_Menuitem_Title, "Quit", MUIA_Menuitem_Shortcut, "Q", End,
End,
MUIA_Family_Child, MenuObject,
MUIA_Menu_Title, "Search",
MUIA_Family_Child, mui_seek = MenuitemObject, MUIA_Menuitem_Title, "Search", MUIA_Menuitem_Shortcut, "S", End,
MUIA_Family_Child, mui_fwd = MenuitemObject, MUIA_Menuitem_Title, "Search forward", MUIA_Menuitem_Shortcut, "F", End,
MUIA_Family_Child, mui_bwd = MenuitemObject, MUIA_Menuitem_Title, "Search backward", MUIA_Menuitem_Shortcut, "B", End,
End,
End,
WindowContents, VGroup,
Child, mui_pgrp = NewObject( CL_Popgroup->mcc_Class, NULL, TAG_DONE ),
End,
TAG_DONE
);
if( obj ) wndcnt++;
data = INST_DATA( cl, obj ); // make Objects private
data->mui_popgroup = mui_pgrp;
data->mui_new = mui_new;
data->mui_open = mui_open;
data->mui_prt = mui_prt;
data->mui_quit = mui_quit;
data->mui_about = mui_about;
data->mui_muiab = mui_muiab;
data->mui_seek = mui_seek;
data->mui_fwd = mui_fwd;
data->mui_bwd = mui_bwd;
DoMethod( obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, obj, 1, MUIM_Mainwin_Close );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "p", data->mui_popgroup, 2, MUIM_Popgroup_Pop, "t" );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "-repeat Up", data->mui_popgroup, 1, MUIM_Textwd_Up );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "-repeat Down", data->mui_popgroup, 1, MUIM_Textwd_Down );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "-repeat shift up", data->mui_popgroup, 1, MUIM_Textwd_Back );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "-repeat shift down", data->mui_popgroup, 1, MUIM_Textwd_Next );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "-repeat Left", data->mui_popgroup, 1, MUIM_Textwd_Back );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "-repeat Right", data->mui_popgroup, 1, MUIM_Textwd_Next );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "s", data->mui_popgroup, 1, MUIM_Popgroup_Gname );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "f", data->mui_popgroup, 1, MUIM_Textwd_Nsk );
DoMethod( obj, MUIM_Notify, MUIA_Window_InputEvent, "b", data->mui_popgroup, 1, MUIM_Textwd_Bsk );
DoMethod( data->mui_about, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 1, MUIM_Mainwin_About );
DoMethod( data->mui_muiab, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 1, MUIM_Mainwin_Abmui );
DoMethod( data->mui_new, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 1, MUIM_Mainwin_New );
DoMethod( data->mui_open, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, data->mui_popgroup, 1, MUIM_Popgroup_Freq );
DoMethod( data->mui_prt, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, data->mui_popgroup, 1, MUIM_Textwd_Prt );
DoMethod( data->mui_quit, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 1, MUIM_Mainwin_Quit );
DoMethod( data->mui_seek, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, data->mui_popgroup, 1, MUIM_Popgroup_Gname );
DoMethod( data->mui_fwd, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, data->mui_popgroup, 1, MUIM_Textwd_Nsk );
DoMethod( data->mui_bwd, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, data->mui_popgroup, 1, MUIM_Textwd_Bsk );
return (ULONG)obj;
}
__saveds __asm ULONG Mainwin_Dispatcher( register __a0 struct IClass *cl, register __a2 Object *obj, register __a1 Msg msg )
{ struct Mainwin_Data *data = INST_DATA( cl, obj );
switch (msg->MethodID)
{
case OM_NEW: return Mainwin_New ( cl, obj, (APTR)msg );
case MUIM_Mainwin_Quit : return Mainwin_Quit ( cl, obj, (APTR)msg );
case MUIM_Mainwin_About: return Mainwin_About ( cl, obj, (APTR)msg );
case MUIM_Mainwin_Abmui: return Mainwin_Abmui ( cl, obj, (APTR)msg );
case MUIM_Mainwin_Close: return Mainwin_Close ( cl, obj, (APTR)msg );
case MUIM_Mainwin_New : return Mainwin_Newwin( cl, obj, (APTR)msg );
}
if( (msg->MethodID)>>8 == Textwd_Base ) // If Message for Textwd-Class...
{ return (ULONG)DoSuperMethodA( CL_Popgroup, data->mui_popgroup, msg );
}
if( (msg->MethodID)>>8 == Popgroup_Base ) // If Message for Popgroup-Class...
{ return (ULONG)DoSuperMethodA( CL_Popgroup, data->mui_popgroup, msg );
}
return (ULONG)DoSuperMethodA( cl, obj, msg );
}